package com.demoReflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class test2Constructor {
    public static void main(String[] args) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        Class cl = Student.class;
        Constructor[] constructors = cl.getConstructors();
        for(Constructor c : constructors) {
            System.out.println(c.getName()+ "------>" + c.getParameterCount() );
        }
        Constructor constructor2 = cl.getDeclaredConstructor(Integer.class,String.class,String.class);
        System.out.println(constructor2.getName()+ "------>" + constructor2.getParameterCount());
        Student stu1= (Student) constructor2.newInstance(1, "enhang","chen");
        System.out.println(stu1);
    }

}
